<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015/11/28
 * Time: 11:22
 */

/**计算日期相差天数
 * @param $day1 开始日期
 * @param $day2 结束日期
 * @return int 如果开始日期大于结束日期 返回0 否则返回天数
 */


//发送httpget请求 获取json对象
function httpGetJSON($url)
{
    //初始化curl
    $ch = curl_init();
    //设置超时
    curl_setopt($ch, CURLOPT_TIMEOUT, 5000);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,FALSE);
    curl_setopt($ch, CURLOPT_HEADER, FALSE);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    //运行curl，结果以json形式返回
    $res = curl_exec($ch);
    curl_close($ch);
    return json_decode($res);
}
